from selenium.webdriver.common.by import By
from autoTest_ecshop.base_page.base import BasePage
from autoTest_ecshop.utils.log_util import logger


class LoginPage(BasePage):
    username_loc = (By.CSS_SELECTOR, '[name="username"]')

    password_loc = (By.CSS_SELECTOR, '[name="password"]')

    loginBtn_loc = (By.CSS_SELECTOR, '[name="submit"]')

    homePage_loc = (By.XPATH, '//*[@id="ECS_MEMBERZONE"]')

    usernameErr_loc = (By.XPATH, '//div[@align="center"]/div/p[1]')

    def loginSystem(self, username, passsword):
        logger.info("输入用户名")
        self.input_data(self.username_loc, username)
        logger.info("输入密码")
        self.input_data(self.password_loc, passsword)
        logger.info("点击登录按钮")
        self.click_btn(self.loginBtn_loc)
